<?php
/*********************************************************************************
 * SugarCRM is a customer relationship management program developed by
 * SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License version 3 as published by the
 * Free Software Foundation with the addition of the following permission added
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Affero General Public License along with
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA.
 * 
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 * 
 * The interactive user interfaces in modified source and object code versions
 * of this program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU Affero General Public License version 3.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 * these Appropriate Legal Notices must retain the display of the "Powered by
 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
 * technical reasons, the Appropriate Legal Notices must display the words
 * "Powered by SugarCRM".
 ********************************************************************************/
$dictionary['edanz_Feedback'] = array(
	'table'=>'edanz_feedback',
	'audited'=>true,
	'fields'=>array (
		'feedback_number' => array (
			'name' => 'feedback_number',
			'vname' => 'LBL_FEEDBACK_NUMBER',
			'type' => 'int',
			'len' => 11,
			'required' => true,
			'auto_increment' => true,
			'unified_search' => true,
			'comment' => 'Visual unique identifier',
			'duplicate_merge' => 'disabled',
			'disable_num_format' => true,
		),
		'quality_rating' => array (
			'name' => 'quality_rating',
			'vname' => 'LBL_QUALITY_RATING',
			'type' => 'radioenum',
			'options' => 'quality_ratings',
			'dbType' => 'double',
			'audited' => true,
		),
		'feedbackpoints'=> array (
                        'name' => 'feedbackpoints',
        	        'type' => 'link',
                	'relationship' => 'feedback_point_feedback',
              	  	'source'=>'non-db',
                ),
		'related_editor_id' =>
			array (
				'name' => 'related_editor_id',
		        'comment' => 'Intended for prospective editor to whom the recruitment task relates',
		        'vname'=>'LBL_RELATED_EDITOR_ID',
		        'rname' => 'id',
		        'type' => 'id',
		        'dbType'=>'id',
		        'table' => 'users',
		        'isnull' => 'true',
		        'module' => 'edanz_Editor',
		        'reportable'=>false,
		        'massupdate' => false,
		        'duplicate_merge'=> 'disabled',
		        'audited' => true,
			),
		 'related_editor_name' =>
		 array (
			    'name'=>'related_editor_name',
                'rname'=>'name',
//				'db_concat_fields'=> array('first_name', 'last_name'),
                'id_name'=>'related_editor_id',
                'vname'=>'LBL_RELATED_EDITOR',
                'type'=>'relate',
				'link'=>'related_editor_link',
                'isnull'=>'true',
                'table' => 'users',
                'module'=>'edanz_Editor',
                'source' => 'non-db',
		 ),
		'related_editor_link' =>
		  array (
					'name' => 'related_editor_link',
					'type' => 'link',
					'vname'=>'LBL_RELATED_EDITOR_LINK',
					'source' => 'non-db',
					'relationship' => 'feedback_related_editor',
		),
		
		'deliverable_id' => array (
			'name' => 'deliverable_id',
			'vname'=>'LBL_DELIVERABLE_ID',
			'rname' => 'id',
			'type' => 'id',
			'dbType'=>'id',
			'table' => 'edanz_deliverables',
			'isnull' => 'true',
			'module' => 'edanz_Deliverables',
			'massupdate' => true,
			'duplicate_merge'=> 'disabled',
		),
		'deliverable_name' => array (
			'name' => 'deliverable_name',
			'link'=>'deliverable_link' ,
			'vname' => 'LBL_DELIVERABLE',
			'rname' => 'name',
			'type' => 'relate',
			'reportable'=>false,
			'source'=>'non-db',
			'table' => 'edanz_deliverables',
			'id_name' => 'deliverable_id',
			'module'=>'edanz_Deliverables',
			'duplicate_merge'=>'disabled',
			'required' => true,
		),
		'deliverable_link' => array (
			'name' => 'deliverable_link',
			'type' => 'link',
			'relationship' => 'feedback_deliverable',
			'vname' => 'LBL_DELIVERABLE',
			'link_type' => 'one',
			'module'=>'edanz_Deliverables',
			'bean_name'=>'edanz_Deliverable',
			'source'=>'non-db',
			'duplicate_merge'=>'enabled',
			'rname' => 'name',
			'id_name' => 'deliverable_id',
			'table' => 'edanz_deliverables',
		),
		'emails' => array (
			'name' => 'emails',
			'type' => 'link',
			'relationship' => 'emails_feedback_rel',
			'source'=>'non-db',
			'vname'=>'LBL_EMAILS',
			'unified_search'=>true,
		),
	),
	'relationships'=>array (
		'feedback_related_editor' => array(
			'lhs_module'=> 'edanz_Editor',
			'lhs_table'=> 'users',
			'lhs_key' => 'id',
			'rhs_module'=> 'edanz_Feedback',
			'rhs_table'=> 'edanz_feedback',
			'rhs_key' => 'related_editor_id',
			'relationship_type'=>'one-to-many'
		),
		'feedback_deliverable' => array(
			'lhs_module'=> 'edanz_Deliverables',
			'lhs_table'=> 'edanz_deliverables',
			'lhs_key' => 'id',
			'rhs_module'=> 'edanz_Feedback' ,
			'rhs_table'=> 'edanz_feedback',
			'rhs_key' => 'deliverable_id',
			'relationship_type'=>'one-to-many'
		),
),
	'indices'=>array(
		 'number'=>array('name' =>'edanz_feedback_numk', 'type' =>'unique', 'fields'=>array('feedback_number'))
	),
	'optimistic_locking'=>true,
);
if (!class_exists('VardefManager')){
        require_once('include/SugarObjects/VardefManager.php');
}
VardefManager::createVardef('edanz_Feedback','edanz_Feedback', array('basic'));

$dictionary['edanz_Feedback']['fields']['name']['type'] = 'enum';
$dictionary['edanz_Feedback']['fields']['name']['audited'] = true;
$dictionary['edanz_Feedback']['fields']['description']['audited'] = true;
$dictionary['edanz_Feedback']['fields']['name']['options'] = 'feedback_name_dom';

// Security Suite Groups
global $beanList;
if (isset($beanList['SecurityGroups'])) {
	$dictionary["edanz_Feedback"]["fields"]["securitygroups_edanz_feedback"] = array (
	  'name' => 'securitygroups_edanz_feedback',
	  'type' => 'link',
	  'relationship' => 'securitygroups_edanz_feedback',
	  'source' => 'non-db',
	  'vname' => 'LBL_SECURITYGROUPS_SUBPANEL_TITLE',
	);
	$dictionary["edanz_Feedback"]["relationships"]["securitygroups_edanz_feedback"] = array (
		'lhs_module' => 'SecurityGroups',
		'lhs_table' => 'securitygroups',
		'lhs_key' => 'id',
		'rhs_module' => 'edanz_Feedback',
		'rhs_table' => 'edanz_feedback',
		'rhs_key' => 'id',
		'join_table' => 'securitygroups_records',
		'join_key_lhs' => 'securitygroup_id',
		'join_key_rhs' => 'record_id',
		'relationship_type' => 'many-to-many',
		'relationship_role_column' => 'module',
		'relationship_role_column_value' => 'edanz_Feedback',
	);

global $moduleAssocFieldsArray;
$moduleAssocFieldsArray['edanz_Feedback'] = array(
	 'related_editor_id' =>
          array('table_name' => 'users',
            	'select_field_name' => 'user_name',
            	'select_field_join'  => 'id',
          ),   
 );  
}
